Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Windows.Forms

Public Class FrmCrTonCongNo_KhachHang
    Private thang, nam, sqlQuery, reportPath As String
    Private customerReport As ReportDocument
    Private flagInHoaDon As Integer = 0

    Private Sub FrmCrTonCongNo_KhachHang_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        frmLoading.Show()
        sqlQuery = "SELECT t1.*, t2.ten_nhacungcap as ten_khachhang  FROM tbl_dot_toncongno_khachhang as t1,"
        sqlQuery += "tbl_khachhang as t2 Where t1.ma_khachhang=t2.ma_nhacungcap and  recycleID='" & nam & thang & "' "
        sqlQuery += "AND(t1.thanhtien_dauky <> 0 OR t1.phatsinhno_trongky <> 0 OR t1.thanhtoan_trongky OR t1.thanhtien_cuoiky <> 0)"
        sqlQuery += " ORDER BY t2.ma_nhacungcap "
        If flagInHoaDon = 0 Then
            reportPath = Application.StartupPath & "\" & "CrTonCongNoKhachHang.rpt"
        Else
            reportPath = Application.StartupPath & "\" & "CrTonCongNoKhachHang_ketoan.rpt"
        End If
        customerReport = New ReportDocument()
        customerReport.Load(reportPath)
        customerReport.SetDataSource(moduleReportConfig.GetDataTable(sqlQuery))
        customerReport.SetParameterValue("TThang", thang)
        customerReport.SetParameterValue("TNam", nam)
        customerReport.SetParameterValue("company", globalVariale.COMPANY)
        customerReport.SetParameterValue("address", globalVariale.ADDRESS)
        customerReport.SetParameterValue("ketoantruong", globalVariale.KETOANTRUONG)
        Me.CrNXTTongHopview.ReportSource = customerReport
        frmLoading.Close()
        frmLoading.Dispose()
    End Sub

    Public Sub setThang(ByVal s As String)
        thang = s
    End Sub

    Public Sub setNam(ByVal s As String)
        nam = s
    End Sub
    Public Sub setInHoaDon(ByVal s As Integer)
        Me.flagInHoaDon = s
    End Sub


End Class
